home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 351-375 / disk_351 / pdc / libsrc.lzh / LibSrc / Math / asinh.c < prev    next >
C/C++ Source or Header  |  1990-04-07  |  3KB  |  96 lines

  1. /************************************************************************
  2.  *                                                                      *
  3.  *                              N O T I C E                             *
  4.  *                                                                      *
  5.  *                      Copyright Abandoned, 1987, Fred Fish            *
  6.  *                                                                      *
  7.  *      This previously copyrighted work has been placed into the       *
  8.  *      public domain by the author (Fred Fish) and may be freely used  *
  9.  *      for any purpose, private or commercial.  I would appreciate     *
  10.  *      it, as a courtesy, if this notice is left in all copies and     *
  11.  *      derivative works.  Thank you, and enjoy...                      *
  12.  *                                                                      *
  13.  *      The author makes no warranty of any kind with respect to this   *
  14.  *      product and explicitly disclaims any implied warranties of      *
  15.  *      merchantability or fitness for any particular purpose.          *
  16.  *                                                                      *
  17.  ************************************************************************
  18.  */
  19.  
  20. /*
  21.  *  FUNCTION
  22.  *
  23.  *      asinh   double precision hyperbolic arc sine
  24.  *
  25.  *  KEY WORDS
  26.  *
  27.  *      asinh
  28.  *      machine independent routines
  29.  *      math libraries
  30.  *
  31.  *  DESCRIPTION
  32.  *
  33.  *      Returns double precision hyperbolic arc sine of double precision
  34.  *      floating point number.
  35.  *
  36.  *  USAGE
  37.  *
  38.  *      double asinh (x)
  39.  *      double x;
  40.  *
  41.  *  RESTRICTIONS
  42.  *
  43.  *      The domain of the ASINH function is the entire real axis
  44.  *      however the evaluation of x squared may cause overflow
  45.  *      for large magnitudes.
  46.  *
  47.  *      For precision information refer to documentation of the
  48.  *      floating point library routines called.
  49.  *      
  50.  *  PROGRAMMER
  51.  *
  52.  *      Fred Fish
  53.  *
  54.  *  INTERNALS
  55.  *
  56.  *      Computes asinh(x) from:
  57.  *
  58.  *              1.      Let xmax = sqrt(MAXDOUBLE - 1)
  59.  *                      
  60.  *              2.      If x < -xmax or xmax < x then
  61.  *                      let x = xmax and flag overflow.
  62.  *
  63.  *              3.      asinh(x) = log [x+sqrt(x**2 + 1)]
  64.  *
  65.  */
  66.  
  67. #include <stdio.h>
  68. #include "pml.h"
  69.  
  70. static char funcname[] = "asinh";
  71.  
  72. double asinh (x)
  73. double x;
  74. {
  75.     struct exception xcpt;
  76.     extern double log ();
  77.     extern double sqrt ();
  78.  
  79.     DBUG_ENTER (funcname);
  80.     DBUG_3 ("asinhin", "arg %le", x);
  81.     if (x < -SQRT_MAXDOUBLE || x > SQRT_MAXDOUBLE) {
  82.         xcpt.type = OVERFLOW;
  83.         xcpt.name = funcname;
  84.         xcpt.arg1 = x;
  85.         if (!matherr (&xcpt)) {
  86.             fprintf (stderr, "%s: OVERFLOW error\n", funcname);
  87.             errno = ERANGE;
  88.             xcpt.retval = log (2 * SQRT_MAXDOUBLE);
  89.         }
  90.     } else {
  91.         xcpt.retval = log (x + sqrt(x*x + 1.0));
  92.     }
  93.     DBUG_3 ("asinhout", "result %le", xcpt.retval);
  94.     DBUG_RETURN (xcpt.retval);
  95. }
  96.